﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpeedByTimeFactor : EffectFactorBase
{
	
	protected float duration;
	protected float speedAffect;

	protected float time;
	public SpeedByTimeFactor(float _duration, float _affect)
	{
		this.duration = _duration;
		this.speedAffect = _affect;
		time = 0;
		Factor = "SpeedByTimeFactor";
	}

	public override void EndEffect(RoleAtrEntity role)
	{
		base.EndEffect(role);
		role.SpeedPlus -= speedAffect; 
	}

	public override void StartEffect(RoleAtrEntity role)
	{
		base.StartEffect(role);
		role.SpeedPlus += speedAffect;
	}

	public override void Tick(RoleAtrEntity role, float deltaTime)
	{
		base.Tick(role, deltaTime);
		time += deltaTime;
		if(time >= duration)
		{
			role.RemoveFactor(this);
		}	
	}

	public override void ReFresh()
	{
		base.ReFresh();
		time = 0;
	}
}
